package com.softstao.guoyu.mvp.interactor.sale;

import com.softstao.guoyu.global.APIInterface;
import com.softstao.guoyu.model.sale.MonthSales;
import com.softstao.guoyu.model.sale.FromOrderList;
import com.softstao.guoyu.model.sale.OrderDetail;
import com.softstao.guoyu.model.sale.PayCondition;
import com.softstao.guoyu.model.sale.ShippingCondition;
import com.softstao.guoyu.model.sale.ToOrderList;
import com.softstao.guoyu.mvp.interactor.BaseInteractor;
import com.softstao.guoyu.utils.MyHttpParams;

import rx.functions.Action1;

/**
 * Created by vaikus on 2017/6/15.
 */

public class OrderInteractor extends BaseInteractor {
    public void getMonthSales(int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId);
        builder.setAction(action1)
                .setUrl(APIInterface.MONTH_SALES_AMOUNT)
                .setType(MonthSales.class)
                .getVolley()
                .post(params);
    }

    public void getFromAgentOrderList(int page, int agentId, String orderState, String search, int isPay,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderState", orderState,
                                                "search", search, "isPay", isPay, "pageSize","4", "pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.TO_AGENT_ORDER)
                .setType(FromOrderList.class)
                .getVolley()
                .post(params);
    }

    public void getToAgentOrderList(int page, int agentId, String orderState, String search, int isPay, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderState", orderState,
                "search", search, "isPay", isPay, "pageSize","4", "pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.FROM_AGENT_ORDER)
                .setType(ToOrderList.class)
                .getVolley()
                .post(params);
    }

    public void getTransferOrderList(int page, int agentId, String orderState, String search, int isPay, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderState", orderState,
                "search", search, "isPay", isPay, "pageSize","4", "pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.TRANSFER_ORDER)
                .setType(ToOrderList.class)
                .getVolley()
                .post(params);
    }

    public void getOrderDetail(int agentId, String orderCode, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_DETAIL)
                .setType(OrderDetail.class)
                .getVolley()
                .post(params);
    }

    public void orderCancel(int agentId, String orderCode, String cancelReason, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode, "cancelReason",cancelReason);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_CANCEL)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderConfirmIncome(int agentId, String orderCode, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_CONFIRM_INCOME)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderRejectIncome(int agentId, String orderCode, String reason, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode, "reason", reason);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_REJECT_INCOME)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderSubmitShipping(ShippingCondition condition, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_SUBMIT_SHIPPING)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderPay(PayCondition condition, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_PAY)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderConfirm(int agentId, String orderCode, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_CONFIRM)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderResubmit(int agentId, String orderCode, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_RESUBMIT)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderTransfer(int agentId, String orderCode, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_TRANSFER)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderReceive(int agentId, String orderCode, Action1<Object> action1) {
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_RECEIVE)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderRevoke(int agentId, String orderCode, Action1<Object> action1) {
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_REVOKE)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void orderDelete(int agentId, String orderCode, Action1<Object> action1) {
        MyHttpParams params = new MyHttpParams("agentId", agentId, "orderCode", orderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.ORDER_DELETE)
                .setType(null)
                .getVolley()
                .post(params);
    }
}
